package com.bjyhl.medical.main.video;

import android.graphics.Color;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.AppCompatImageView;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import com.bjyhl.core.fragments.LatteFragment;
import com.bjyhl.medical.R;
import com.bjyhl.medical.main.EcBottomFragment;
import com.bjyhl.medical.main.news.NewsFragment;
import com.bjyhl.medical.main.news.list.NewsListFragment;
import com.bjyhl.ui.recycler.ItemType;
import com.bjyhl.ui.recycler.MultipleFields;
import com.bjyhl.ui.recycler.MultipleItemEntity;
import com.bjyhl.ui.recycler.MultipleViewHolder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;

import java.util.List;

import me.yokeyword.fragmentation.SupportHelper;

public class VideoListRecyclerAdapter extends
        BaseMultiItemQuickAdapter<MultipleItemEntity, MultipleViewHolder> {

    private static final RequestOptions REQUEST_OPTIONS =
            new RequestOptions()
                    .centerCrop()
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
                    .dontAnimate();

    protected VideoListRecyclerAdapter(List<MultipleItemEntity> data) {
        super(data);
        //添加横排菜单布局
        addItemType(ItemType.VIDEO, R.layout.item_video_list);
    }

    @Override
    protected void convert(MultipleViewHolder holder, MultipleItemEntity item) {
        switch (holder.getItemViewType()) {
            case ItemType.VIDEO:
                final String title = item.getField(MultipleFields.TITLE);
                final String imageUrl = item.getField(MultipleFields.IMAGE_URL);


//                final View itemView = holder.itemView;
//                itemView.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View view) {
//                        // 点击播放视频
//                        final int currentPosition = holder.getAdapterPosition();
//                        final String videoUrl = getData().get(currentPosition).getField(MultipleFields.CONTENT);
//                        Toast.makeText(mContext, videoUrl, Toast.LENGTH_SHORT);
//                    }
//                });

                holder.setText(R.id.tv_rv_video, title);
                Glide.with(mContext)
                        .load(imageUrl)
                        .apply(REQUEST_OPTIONS)
                        .into((ImageView) holder.getView(R.id.image_rv_video));


                break;
            default:
                break;
        }
    }



}
